Force Cell Click
Force Cell Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : May 2025.
- Type : ADC/I2C type
Software Support
Example Description
This example demonstrates the use of the Force Cell Click board by reading the applied force in newtons (N) from a load cell sensor. The application initializes the driver, calibrates the offset, and continuously measures and logs the force value to the USB UART terminal.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.ForceCell
Example Key Functions
- forcecell_cfg_setup This function initializes Click configuration structure to initial values.
void forcecell_cfg_setup(forcecell_cfg_t *cfg)
Force Cell configuration object setup function.
Force Cell Click configuration object.
Definition forcecell.h:163
- forcecell_init This function initializes all necessary pins and peripherals used for this Click board.
err_t forcecell_init(forcecell_t *ctx, forcecell_cfg_t *cfg)
Force Cell initialization function.
Force Cell Click context object.
Definition forcecell.h:147
- forcecell_calib_offset This function calibrates the zero force offset value.
err_t forcecell_calib_offset(forcecell_t *ctx)
Force Cell calib offset function.
- forcecell_read_force This function reads the applied force level [N].
err_t forcecell_read_force(forcecell_t *ctx, float *force)
Force Cell read force function.
Application Init
Initializes the logger and the Click driver, performs offset calibration to null the load cell.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Offset calibration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ FORCECELL_ERROR
Definition forcecell.h:185
#define FORCECELL_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition forcecell.h:123
void application_init(void)
Definition main.c:29
Application Task
Continuously reads and displays the current force value in newtons every 100ms.
{
float force = 0;
{
log_printf( &logger, " Force : %.3f N\r\n\n", force );
Delay_ms ( 100 );
}
}
@ FORCECELL_OK
Definition forcecell.h:184
void application_task(void)
Definition main.c:66
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.